<template>
  <div class="app-container">
    <el-card class="box-card">
      <el-row class="btns">
        <el-button type="danger" size="small" @click="delIndex"
          >删除ElasticSearch索引</el-button
        >
        <el-button type="primary" size="small" @click="addCourse"
          >添加课程全局搜索数据</el-button
        >
        <el-button type="primary" size="small" @click="addBlog"
          >添加课程文章搜索数据</el-button
        >
        <el-button type="primary" size="small" @click="addResource"
          >添加课程资源搜索数据</el-button
        >
      </el-row>
     
    </el-card>
  </div>
</template>

<script>
import elasticSearchApi from "@/api/elasticSearch";
export default {
  name: "elasticSearch",
  data() {
    return {
      
    };
  },
  created() {
    
  },
  methods: {
    async delIndex(){
      let res = elasticSearchApi.deleteIndex("running_together")
      if(res.success) {
        this.$message.success("删除ElasticSearch索引成功")
      }else{
        this.$message.error("删除ElasticSearch索引失败")
      }
    },
    async addCourse(){
      let res = elasticSearchApi.addCourse()
      if(res.success) {
        this.$message.success("添加课程数据到ElasticSearch成功")
      }else{
        this.$message.error("添加课程数据到ElasticSearch失败")
      }
    },
    async addBlog(){
      let res = elasticSearchApi.addBlog()
      if(res.success) {
        this.$message.success("添加文章数据到ElasticSearch成功")
      }else{
        this.$message.error("添加文章数据到ElasticSearch失败")
      }
    },
    async addResource(){
      let res = elasticSearchApi.addResource()
      if(res.success) {
        this.$message.success("添加资源数据到ElasticSearch成功")
      }else{
        this.$message.error("添加资源数据到ElasticSearch失败")
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.btns{
  display: flex;
  justify-content: space-around;
}
</style>